home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / vidhandl / fontresz.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-03  |  2.2 KB  |  90 lines

  1. /* FONTRESIZE - Resizes the character height of .FNT files          */
  2. /* Freeware version                                                 */
  3. /* By Marcio Afonso Arimura Fialho                                  */
  4. /* http://pessoal.iconet.com.br/jlfialho                            */
  5. /* e-mail: jlfialho@iconet.com.br or (alternate) jlfialho@yahoo.com */
  6.  
  7. #include <stdio.h>
  8. #include <conio.h>
  9. #include <string.h>
  10.  
  11. #include "readname.cpp"
  12.  
  13. void main (int n, char *ent[5])
  14.  {
  15.     FILE *source,*target;
  16.     int c0,c1;
  17.     int a0,a1;
  18.     int k;
  19.     char path[132];
  20.  
  21.     char c;
  22.     char info[]="\nType FONTRESZ with no parameters for help\n";
  23.     if (n==1)
  24.      {
  25.         printf ("\tFONTRESZ ver 1.0 - - - DOS FONT RESIZER - - - FREEWARE VERSION\n\n\
  26. \tUsage:\tFONTRESZ source[.fnt] s_heigh target[.fnt] s_target\n\n");
  27.         printf ("Where: s_heigh is the heigh of caracters patterns in source file and\n\
  28. \40\40\40\40\40\40 s_target is the heigh of characters patterns in target file\n\n");
  29.         printf ("By Marcio Afonso Arimura Fialho\nhtpp://pessoal.iconet.com.br/jlfialho\n");
  30.         return;
  31.      }
  32.     if (n<4)
  33.      {
  34.         printf ("ERROR: FEW PARAMETERS%s",info);
  35.         return;
  36.      }
  37.  
  38.     readfname (path, ent[1], ".FNT");
  39.     source=fopen (path,"rb");
  40.     if(source==NULL)
  41.      {
  42.         printf ("ERROR: FILE %s COULDN'T BE OPEN TO READ%s",ent[1],info);
  43.         fcloseall();
  44.         return;
  45.      }
  46.     strcpy(path, ent[3]);
  47.     if (strchr(path,'.')==NULL)
  48.         strcat(path,".FNT");
  49.     target=fopen (path,"rb");
  50.     if (target!=NULL)
  51.         do
  52.          {
  53.             printf ("\nFILE %s already exists. Overwrite (Y/N)?",path);
  54.             k=getche();
  55.             if (k>0x60)
  56.                 k-=0x20;
  57.             if (k=='N')
  58.              {
  59.                 fcloseall();
  60.                 return;
  61.              }
  62.          }
  63.          while (k!='N' && k!='Y');
  64.     target=fopen (path,"wb");
  65.     if(target==NULL)
  66.      {
  67.         printf ("ERROR: FILE %s COULDN'T BE OPEN TO WRITE%s",ent[3],info);
  68.         fcloseall();
  69.         return;
  70.      }
  71.     sscanf(ent[2],"%d",&a0);
  72.     sscanf(ent[4],"%d",&a1);
  73.  
  74.     if (a0<0 || a0>256 || a1<0 || a1>256)
  75.      {
  76.         printf ("ERROR: INPUT VALUES OUT OF RANGE%s",info);
  77.         fcloseall();
  78.         return;
  79.      }
  80.     for (c0=0;c0<256;c0++)
  81.      {
  82.         for (c1=0;c1<a0;c1++)
  83.             path[c1]=fgetc(source);
  84.         for (c1=0;c1<a1;c1++)
  85.             fputc(path[c1*a0/a1],target);
  86.      }
  87.     fseek(target,-1,2);
  88.     fcloseall ();
  89.  }
  90.